<template>
  <div class="tab-bar">
    
    <div class="tab-item" :class="{ active: currentRoute === '/home' }" @click="navigateTo('/home')">首页</div>
    <div class="tab-item" :class="{ active: currentRoute === '/article' }" @click="navigateTo('/article')">文章列表</div>
    <div class="tab-item" :class="{ active: currentRoute === '/notify' }" @click="navigateTo('/notify')">消息通知</div>
    <div class="tab-item" :class="{ active: currentRoute === '/user' }" @click="navigateTo('/user')">我的</div>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router'

const router = useRouter()
const currentRoute = useRouter().currentRoute.value.path

function navigateTo(path) {
  router.push(path)
}
</script>

<style scoped>
.tab-bar {
  display: flex;
  background-color: #f5f5f5;
  padding: 10px 0;
}

.tab-item {
  flex: 1;
  padding: 10px;
  cursor: pointer;
}

.tab-item.active {
  font-weight: bold;
  color: #007bff;
}
</style>